import Vue from 'vue'
import App from './App.vue'
import router from './router'
import moment from 'moment'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './style/common.scss'; //重置样式
import './common/js/three.min.js'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(VueQuillEditor)
//全局过滤器
Vue.filter('dateformat', function(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
    return moment(dataStr).format(pattern)

})
//验证是否已登录
router.beforeEach((to, from, next) => {
    if (to.path == '/login') {
        sessionStorage.removeItem('YX-TOKEN');
    }
    //判断进入的页面需不需要登录
    if (to.matched.some(res => res.meta.requireAuth)) {
        if (sessionStorage.getItem('YX-TOKEN')) {
            next()
            return false;
        } else {
            next({ path: '/login' })
        }
    } else {
        next()
    }
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
